import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("device_id", ["deviceId"], {})
@Index("user_id", ["userId"], {})
@Entity("water_test", { schema: "bacsense_water" })
export class WaterTest {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("int", { name: "user_id", unsigned: true, default: () => "'0'" })
  userId: number;

  @Column("int", { name: "device_id", unsigned: true, default: () => "'0'" })
  deviceId: number;

  @Column("tinyint", {
    name: "type",
    comment: "检测类型",
    unsigned: true,
    default: () => "'0'",
  })
  type: number;

  @Column("tinyint", {
    name: "status",
    comment: "0：等待开启，1：检测中，2：检测失败，3，结束检测，4：检测完成",
    unsigned: true,
    default: () => "'0'",
  })
  status: number;

  @Column("smallint", { name: "result", unsigned: true, default: () => "'0'" })
  result: number;

  @Column("json", { name: "data", nullable: true })
  data: {time:number; lux:number}[];

  @Column("int", {
    name: "end_time",
    comment: "创建时间",
    unsigned: true,
    default: () => "'0'",
  })
  endTime: number;

  @Column("int", {
    name: "create_time",
    comment: "创建时间",
    unsigned: true,
    default: () => "'0'",
  })
  createTime: number;
}
